package com.java.reggie.utils;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;

@Component
public class SendMailUtil {


    @Autowired
    private JavaMailSender javaMailSender;

    //发送人
    private static String from = "2241943820@qq.com";
    //接收人
    private static String to = "";
    //标题
    private static String subject = "";
    //正文
    private static String contextBefore = "【瑞吉外卖】您正在登录瑞吉外卖平台账号，验证码是：";
    private static String contextAfter = "，3分钟内有效，请及时输入。";


    public void sendMail(String email,String setSubject,String loginCode) {

        SimpleMailMessage message = new SimpleMailMessage();
        to = email;
        subject = setSubject;

        message.setFrom(from+"(瑞吉外卖)");
        message.setTo(to);
        message.setSubject(subject);
        message.setText(contextBefore + loginCode + contextAfter);
        javaMailSender.send(message);
    }


}
